﻿using System;
using System.Windows.Forms;
using aboveApplication;
using Application = aboveApplication.Application;

namespace aboveXWords
{
  public partial class MainForm : Application
  {
    public MainForm()
    {
      InitializeComponent();
    }

    private void MainForm_OnDocumentNew(object sender, DocumentManager.OnDocumentNewEventArgs e)
    {
      e.Document = new XWordDocument(e.Filename, new Canvas(this));
    }

    private void MainForm_OnDocumentOpen(object sender, DocumentManager.OnDocumentOpenEventArgs e)
    {
      e.Document = new XWordDocument(e.Filename, new Canvas(this));
    }

    private void ToolStripButtonAddWordClick(object sender, EventArgs e)
    {
      var xWordDocument = DocumentManager.SelectedAs<XWordDocument>();
      if (xWordDocument == null) return;
      xWordDocument.AddWord();
    }

    private void MainForm_KeyPress(object sender, KeyPressEventArgs e)
    {
      var xWordDocument = DocumentManager.SelectedAs<XWordDocument>();
      if (xWordDocument == null) return;
      xWordDocument.KeyPressed(e);
    }

    private void ToolStripButtonAddPictureClick(object sender, EventArgs e)
    {
      var xWordDocument = DocumentManager.SelectedAs<XWordDocument>();
      if (xWordDocument == null) return;
      xWordDocument.AddPicture();
    }
  }
}